#ifndef __CONSOLE_H
#define __CONSOLE_H
#include <stdarg.h>
#include "matrix.h"
#include "device.h"
#include "mxsetup.h"

/**
 * console configuration:
 *  MXSETUP_CONSOLE_NEWLINE_SPECIAL - (bool) choose `\r\n` or `\n` for new line, default is `\n`
 *  MXSETUP_CONSOLE_USE_LONGLONG - (bool) use `long long` or not
 */

/* ENDL (end with line) definition */
#ifdef MXSETUP_CONSOLE_NEWLINE_SPECIAL
# define CONSOLE_NEWLINE_SPECIAL
# define ENDL "\r\n"
#else
# define ENDL "\n"
#endif

/* initialize console */
void console_init (char* devname, mx_usize_t obufsize);
/* get the device of console */
mx_device_pt console_device (void);
/* print a string on console */
void console (const char* fmt, ...);
/* print a string on console with new line */
void consoleline (const char* fmt, ...);
/* print a char to console */
void console_putc (char c);
/* print a string to console */
void console_puts (mx_string_pt s);
/* string format */
void mx_sprintf (char* buf, mx_usize_t size, const char* fmt, ...);
/* generate a string to the specified buffer by format string ("string %d", var) */
mx_int32_t mx_vsnprintf (char* buf, mx_usize_t size, const char* fmt, va_list args);

#endif
